package com.test23_正则表达式;

import org.junit.Test;

public class Demo01_Test {

    @Test
    public void test1() {
        String str = "1357924680";
        System.out.println(isNumber(str));
    }

    /**
     * 验证字符串是否全部由数字所组成
     * @param str
     * @return
     */
    public static boolean isNumber(String str) {
        for (int x = 0; x < str.length(); x++) {
            if (str.charAt(x) < '0' || str.charAt(x) > '9') {
                return false;
            }
        }
        return true;
    }

    @Test
    public void test2() {
        // 正则验证
        String str = "1357924680";
        System.out.println(str.matches("\\d+"));
    }
}
